home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / Shutdown FX 1.5 source Folder / Shutdown FX ƒ / code ƒ / ◊ init.c next >
Encoding:
C/C++ Source or Header  |  1994-04-09  |  2.6 KB  |  118 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        init.c
  4.  
  5. Purpose:    This module handles INIT initialization and installation.
  6.             
  7.  
  8. Shutdown FX -=- graphic effects on shutdown
  9. Copyright (C) 1993-4, Mark Pilgrim & Dave Blumenthal
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program in a file named "GNU General Public License".
  23. If not, write to the Free Software Foundation, 675 Mass Ave,
  24. Cambridge, MA 02139, USA.
  25.  
  26. \**********************************************************************/
  27.  
  28. #include "init.h"
  29. #include "main.h"
  30. #include "prefs.h"
  31. #include "show init.h"
  32. #include "ShutDown.h"
  33. #include "GestaltEQU.h"
  34. #define        GOOD_ICON                130        /* icons displayed at startup */
  35. #define        BAD_ICON                129
  36.  
  37. Handle            initHandle;            /* handle to main init code */
  38.  
  39. void __GetA4(void)
  40. {
  41.     asm {
  42.         bsr.s    @1
  43.         dc.l    0            ;  store A4 here
  44. @1        move.l    (sp)+,a1
  45.     }
  46. }
  47.  
  48. /* this be the init startup install routine thing */
  49. void main(void)
  50. {
  51.     THz                saveZone;
  52.     long            gestalt_temp;
  53.     OSErr            isHuman;
  54.     
  55.     RememberA0();
  56.     SetUpA4();
  57.     
  58.     isHuman=Gestalt(gestaltFSAttr, &gestalt_temp);
  59.     gHasFSSpecs=((isHuman==noErr) && (gestalt_temp&(1<<gestaltHasFSSpecCalls)));
  60.     
  61.     saveZone = GetZone();
  62.     SetZone(SysZone);
  63.     
  64.     asm
  65.     {
  66.         movea.l            a4, a0
  67.         RecoverHandle
  68.         move.l            a0, initHandle
  69.     }
  70.     if (MemError())
  71.     {
  72.         SetZone(saveZone);
  73.         ShowIconFamily(BAD_ICON);
  74.     }
  75.     else
  76.     {
  77.         HLock(initHandle);
  78.         HNoPurge(initHandle);
  79.         if (DoSetup())    /* everything ok */
  80.         {
  81.             DetachResource(initHandle);
  82.             SetZone(saveZone);
  83.             ShowIconFamily(GOOD_ICON);
  84.         }
  85.         else
  86.         {
  87.             SetZone(saveZone);
  88.             ShowIconFamily(BAD_ICON);
  89.         }
  90.     }
  91.     
  92.     RestoreA4();
  93. }
  94.  
  95. Boolean DoSetup(void)
  96. {
  97.     int                resultCode;
  98.     
  99.     resultCode=PreferencesInit();
  100.     if ((resultCode!=prefs_allsWell) && (resultCode!=prefs_virginErr))
  101.         return FALSE;
  102.     
  103.     gTheDlog=gTheDitl=0L;
  104.     gTheDlog=(DialogTHndl)GetResource('DLOG', 128);
  105.     if (gTheDlog==0L)
  106.         return FALSE;
  107.     gTheDitl=GetResource('DITL', 128);
  108.     if (gTheDitl==0L)
  109.         return FALSE;
  110.     DetachResource(gTheDlog);
  111.     DetachResource(gTheDitl);
  112.     
  113.     ShutDwnInstall((ProcPtr)&sfxShutdownMain, sdOnDrivers+sdOnPowerOff);
  114.     ShutDwnInstall((ProcPtr)&sfxRestartMain, sdOnDrivers+sdOnRestart);
  115.     
  116.     return TRUE;
  117. }
  118.